<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>instruction4</title>
<script src="js/vue.min.js"></script>
</head>
<body>
<div id="app">
    <div v-lz="{ color: 'green', text: 'lz!' }"></div>
</div>

<script>
Vue.directive('lz', function (el, binding) {
  // 简写方式设置文本及背景颜色
  el.innerHTML = binding.value.text
  el.style.backgroundColor = binding.value.color
})
new Vue({
  el: '#app'
})
</script>
</body>
</html>